── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ lubridate::interval() masks tsibble::interval()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# A tsibble: 132 x 2 [1M]
Date Flow
<mth> <dbl>
1 2013 Jan 18.1
2 2013 Feb 18.0
3 2013 Mar 8.21
4 2013 Apr 5.94
5 2013 May 333.
6 2013 Jun 300.
7 2013 Jul 75.6
8 2013 Aug 48.8
9 2013 Sep 1085.
10 2013 Oct 146.
# ℹ 122 more rows
2. Plotting the time series
library(ggplot2)library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
poudre_plot <- poudre_tsbl |>ggplot(aes(x = Date, y = Flow)) +geom_line(color ="purple", linewidth =0.8) +labs(title ="Monthly Average Streamflow in Cache la Poudre River (2013-2023)",x ="Date",y ="Flow (cfs)") +theme_minimal()poudre_plot
ggplotly(poudre_plot)
3. Subseries
gg_subseries(poudre_tsbl) +labs(title ="Monthly Cache la Poudre River Flow Patterns", y ="Flow (cfs)", x ="Year") +theme_minimal()
Plot variable not specified, automatically selected `y = Flow`
Describe what you see in the plot. How are “seasons” defined in this plot? What do you think the “subseries” represent?
Looking at the subseries plot of the Cache la Poudre River, I am able to see a natural rhythm where the river flow has significant peaks in May and June, reaching just above 2000 cfs, before it gradually declines throughout the summer and remains low during winter months. In this plot, “seasons” are defined as calendar months (January through December), with each panel showing how that particular month’s flow patterns changed across the decade of data. The subseries represent the river’s behavior during each specific month across multiple years (2013-2023), which reveals both the river’s consistent seasonal pattern and the year-to-year variations within each month, particularly during the high-flow periods when snowmelt dominates the river’s character.
4. Decompose
poudre_dcmp <- poudre_tsbl |>model(stl =STL(Flow ~trend(window =21) +season(window =13)))components(poudre_dcmp) |>autoplot() +labs(title ="STL Decomposition of Cache la Poudre River Flow")
Describe what you see in the plot. How do the components change over time? What do you think the trend and seasonal components represent?
The STL decomposition shows how the pattern of flow of the Cache la Poudre River combines multi-decade climate trends with frequent seasonal cycles. The trend part shows a distinctive arc - rising steeply from 2013 to peak at 2015-2016 and then dropping before beginning to rise again in more recent years, probably capturing longer-term cycles of wetness and dryness in the watershed. The annual seasonal trend then resumes the cyclic annual snowmelt pattern, and the remaining part highlights unusual events like sudden storms or water management measures that caused the river to behave in manners that its typical patterns could not have expected.